package com.zb.testview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by ZhuBo on 2015/11/6.
 */
public class MyView extends View {


    public MyView(Context context) {
        super(context);
        Log.v("0504", "   ---super(context)---  ");
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        Log.v("0504", "   ---super(context, attrs)---  ");
    }

    public MyView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        Log.v("0504", "   ---super(context, attrs, defStyleAttr)---  ");
    }

    @Override
    protected void onFinishInflate() {
        Log.v("0504", "   ---onFinishInflate---  ");
        super.onFinishInflate();
    }

    @Override
    protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
        Log.v("0504", "   ---onFocusChanged---    gainFocus = " + gainFocus);
        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        Log.v("0504", "   ---onWindowFocusChanged---    hasWindowFocus = " + hasWindowFocus);
        super.onWindowFocusChanged(hasWindowFocus);
    }

    @Override
    protected void onAttachedToWindow() {
        Log.v("0504", "   ---onAttachedToWindow---  ");
        super.onAttachedToWindow();
    }

    @Override
    protected void onVisibilityChanged(View changedView, int visibility) {
        Log.v("0504", "   ---onVisibilityChanged---  visibility =" + visibility
                + "  ,是否是自己 = " + (changedView == this));
        super.onVisibilityChanged(changedView, visibility);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        Log.v("0504", "   ---onSizeChanged---  w = " + w);
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected void onWindowVisibilityChanged(int visibility) {
        Log.v("0504", "   ---onWindowVisibilityChanged---  visibility =" + visibility);
        super.onWindowVisibilityChanged(visibility);
    }

    @Override
    protected void onDetachedFromWindow() {
        Log.v("0504", "   ---onDetachedFromWindow---  ");
        super.onDetachedFromWindow();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        Log.v("0504", "   ---onMeasure---  ");
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        Log.v("0504", "   ---onLayout---  ");
        super.onLayout(changed, left, top, right, bottom);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Log.v("0504", "   ---onDraw---  ");
        super.onDraw(canvas);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        Log.v("0504", "   ---dispatchTouchEvent---  event = " + event.getAction());
        return super.dispatchTouchEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.v("0504", "   ---onTouchEvent---  event = " + event.getAction());
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.v("0504", "   ---onKeyDown---  ");
        return super.onKeyDown(keyCode, event);
    }
}
